<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Hello World</title>
  <script src="https://unpkg.com/vue"></script>

</head>

<body>
  <div id="root"></div>
  <script>
    /* 
      1. 作用域插槽
      - 将子组件中定义的数据通过插槽暴露给父组件中使用
      - 父组件通过v-slot="xxx"接收
    */

    const app = Vue.createApp({
      template: `
        <list v-slot="slotProps">
          <span>{{slotProps.item}}</span>
        </list>
      `
    })
    app.component('list', {
      data(){
        return {
          list: [1,2,3,4]
        }
      },
      template: `<div>
                  <slot v-for="item in list" :item="item"></slot>
                </div>`
    })
    const vm = app.mount('#root');
  </script>
</body>

</html>